local function make_born_point(map_id)
    local configs = IMPORT_D:query("bornpoint")
    if not configs then
        return
    end

    local map_id = 1    ---! 目前有且仅有一张地图
    local config = configs[map_id]
    if not config then
        return
    end

    return random_shuffle(table.keys(config), 8)
end

-------------------------------------------------------------------------------
---! 战斗初始相关处理
-------------------------------------------------------------------------------
local M = {}
COMBAT_D:register_entry("prepare", M)

---! 初始战斗
function M:prepare_combat(combat_ob)
    local map_id = combat_ob:get_map_id()
    local born_seqs = make_born_point(map_id)
    if not born_seqs then
        return false
    end

    local players = combat_ob:get_player_obs()
    if #born_seqs < #players then
        return false
    end

    local init_hp = 5   ---! 初始生命力
    for idx = 1, #players do
        local player = players[idx]
        local born_seq = born_seqs[idx]

        local tank = TANK_OB:create()
        tank:set_id(player:get_tank_id()) 
        tank:set_hp(tank:get_max_hp())
        tank:set_position(born_seq)
        tank:set_camp(idx) ---! 独立阵营，各自为战
        tank:set_owner_id(player:get_id())
        player:set_temp("tank", tank)
        spdlog.debug("combat", "user_id : %s prepare combat : %s tank_id : %s, pos : %s",
                                player:get_id(), combat_ob:get_id(), tank:get_id(), born_seq)
    end

    ---! 记录参加战斗的玩家人数
    combat_ob:set_temp("user_num", #players)
    return true
end
